{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 111616)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 111616)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 111616)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113152)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 114176)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 113664)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112128)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(15, 112640)\n",
      "Setting up band-pass filter from 7 - 35 Hz\n",
      "l_trans_bandwidth chosen to be 2.0 Hz\n",
      "h_trans_bandwidth chosen to be 8.8 Hz\n",
      "Filter length of 845 samples (1.650 sec) selected\n",
      "(2240, 15, 768)\n",
      "(2240,)\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "Format dataset, we read the file for the desired subject, and parse the data to extract:\n",
    "- samplingRate\n",
    "- trialLength\n",
    "- X, a M x N x K matrix, which stands for trial x chan x samples\n",
    "                         the actual values are 160 x 15 x 2560\n",
    "- y, a M vector containing the labels {0,1}\n",
    "\n",
    "ref:\n",
    "Dataset description: https://lampx.tugraz.at/~bci/database/002-2014/description.pdf\n",
    "\"\"\"\n",
    "\n",
    "import scipy.io as sio\n",
    "import numpy as np\n",
    "import sys \n",
    "import mne\n",
    "\n",
    "# prepare data containers\n",
    "y = []\n",
    "X = []\n",
    "\n",
    "trainingFileList = ['../../BBCIData/S14T.mat', \n",
    "                    '../../BBCIData/S13T.mat', \n",
    "                    '../../BBCIData/S12T.mat', \n",
    "                    '../../BBCIData/S11T.mat', \n",
    "                    '../../BBCIData/S10T.mat', \n",
    "                    '../../BBCIData/S09T.mat', \n",
    "                    '../../BBCIData/S08T.mat', \n",
    "                    '../../BBCIData/S07T.mat', \n",
    "                    '../../BBCIData/S06T.mat', \n",
    "                    '../../BBCIData/S05T.mat', \n",
    "                    '../../BBCIData/S04T.mat', \n",
    "                    '../../BBCIData/S03T.mat', \n",
    "                    '../../BBCIData/S02T.mat', \n",
    "                    '../../BBCIData/S01T.mat']\n",
    "\n",
    "validationFileList = ['../../BBCIData/S14E.mat', \n",
    "                      '../../BBCIData/S13E.mat', \n",
    "                      '../../BBCIData/S12E.mat', \n",
    "                      '../../BBCIData/S11E.mat', \n",
    "                      '../../BBCIData/S10E.mat', \n",
    "                      '../../BBCIData/S09E.mat', \n",
    "                      '../../BBCIData/S08E.mat', \n",
    "                      '../../BBCIData/S07E.mat', \n",
    "                      '../../BBCIData/S06E.mat', \n",
    "                      '../../BBCIData/S05E.mat', \n",
    "                      '../../BBCIData/S04E.mat', \n",
    "                      '../../BBCIData/S03E.mat', \n",
    "                      '../../BBCIData/S02E.mat', \n",
    "                      '../../BBCIData/S01E.mat']\n",
    "\n",
    "\n",
    "\n",
    "#trainingFileList = ['BBCIData/S14T.mat']\n",
    "\n",
    "#validationFileList = ['BBCIData/S14E.mat']\n",
    "\n",
    "def filterData(rawData, samplingRate):\n",
    "    print(rawData.shape)\n",
    "    \n",
    "    #filteredData = mne.filter.filter_data()\n",
    "    \n",
    "    filterHandle = mne.filter.create_filter(rawData[0,:], samplingRate, l_freq=7., h_freq=35.)  \n",
    "    filterHalfLenght = len(filterHandle) // 2\n",
    "\n",
    "    filteredData = np.zeros([rawData.shape[0],rawData.shape[1]+filterHalfLenght])\n",
    "\n",
    "    # for each channel\n",
    "    for i in range(rawData.shape[0]):\n",
    "        #filteredData[i,:] = mne.filter.filter_data(rawData[i,:],sfreq=samplingRate ,l_freq=7., h_freq=35.,method='iir')\n",
    "        filteredData[i,:] = np.convolve(filterHandle, rawData[i,:])[len(filterHandle) // 2:]\n",
    "\n",
    "    filteredData = filteredData[:,filterHalfLenght:-filterHalfLenght]\n",
    "    return filteredData\n",
    "    \n",
    "\n",
    "\n",
    "tStart = 3.5\n",
    "tStop = 5.\n",
    "\n",
    "for i in range(len(trainingFileList)):\n",
    "    # read file\n",
    "    d1T = sio.loadmat(trainingFileList[i])\n",
    "    d1E = sio.loadmat(validationFileList[i])\n",
    "    \n",
    "    samplingRate = d1T['data'][0][0][0][0][3][0][0]\n",
    "    trialLength = (int)(tStop*samplingRate)\n",
    "\n",
    "\n",
    "    # run through all training runs\n",
    "    for run in range(5):\n",
    "        y.append(d1T['data'][0][run][0][0][2][0]) # labels\n",
    "        timestamps = d1T['data'][0][run][0][0][1][0] # timestamps\n",
    "        rawData = d1T['data'][0][run][0][0][0].transpose() # chan x data\n",
    "        \n",
    "        rawData = filterData(rawData,samplingRate)\n",
    "        \n",
    "        # parse out data based on timestamps\n",
    "        for start in timestamps:\n",
    "            dstart = (int)(start + tStart*samplingRate)\n",
    "            end = start + trialLength\n",
    "            X.append(rawData[:,dstart:end]) #15 x 2560\n",
    "\n",
    "\n",
    "    # run through all validation runs (we do not discriminate at this point)\n",
    "    for run in range(3):\n",
    "        y.append(d1E['data'][0][run][0][0][2][0]) # labels\n",
    "        timestamps = d1E['data'][0][run][0][0][1][0] # timestamps\n",
    "        rawData = d1E['data'][0][run][0][0][0].transpose() # chan x data\n",
    "\n",
    "        filterData(rawData,samplingRate)\n",
    "        \n",
    "        # parse out data based on timestamps\n",
    "        for start in timestamps:\n",
    "            dstart = (int)(start + tStart*samplingRate)\n",
    "            end = start + trialLength\n",
    "            X.append(rawData[:,dstart:end]) #15 x 2557\n",
    "\n",
    "    del rawData\n",
    "    del d1T\n",
    "    del d1E\n",
    "\n",
    "# arrange data into numpy arrays\n",
    "# also torch expect float32 for samples\n",
    "# and int64 for labels {0,1}\n",
    "X = np.array(X).astype(np.float32)\n",
    "y = (np.array(y).flatten()-1).astype(np.int64)\n",
    "print(X.shape)\n",
    "print(y.shape)\n",
    "\n",
    "# erase unused references\n",
    "d1T = []\n",
    "d1E = []\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/fred/anaconda3/envs/Torch36/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n",
      "  \"This module will be removed in 0.20.\", DeprecationWarning)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch data:\n",
      "(2240, 15, 768)\n",
      "labels:\n",
      "(2240,)\n",
      "Classification accuracy: 0.676339 \n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "====================================================================\n",
    "ERP EEG decoding in Tangent space.\n",
    "====================================================================\n",
    "Decoding applied to EEG data in sensor space decomposed using Xdawn.\n",
    "After spatial filtering, covariances matrices are estimated, then projected in\n",
    "the tangent space and classified with a logistic regression.\n",
    "\"\"\"\n",
    "# Authors: Alexandre Barachant <alexandre.barachant@gmail.com>\n",
    "#\n",
    "# License: BSD (3-clause)\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "from pyriemann.estimation import XdawnCovariances\n",
    "#from pyriemann.tangentspace import TangentSpace\n",
    "from pyriemann.utils.viz import plot_confusion_matrix\n",
    "from pyriemann.estimation import Covariances\n",
    "from pyriemann.classification import TSclassifier, MDM\n",
    "\n",
    "from sklearn.pipeline import make_pipeline\n",
    "from sklearn.cross_validation import KFold\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from random import randint\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "###############################################################################\n",
    "# Decoding in tangent space with a logistic regression\n",
    "\n",
    "n_components = 2  # pick some components\n",
    "\n",
    "labels = y\n",
    "epochs_data = X\n",
    "\n",
    "\n",
    "# Define a monte-carlo cross-validation generator (reduce variance):\n",
    "cv = KFold(len(labels), 10, shuffle=True, random_state=randint(1,5000))\n",
    "\n",
    "print(\"epoch data:\")\n",
    "print(epochs_data.shape)\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "clf = make_pipeline(Covariances('oas'), TSclassifier())\n",
    "\n",
    "preds = np.zeros(len(labels))\n",
    "\n",
    "print(\"labels:\")\n",
    "print(labels.shape)\n",
    "\n",
    "for train_idx, test_idx in cv:\n",
    "    y_train, y_test = labels[train_idx], labels[test_idx]\n",
    "\n",
    "    clf.fit(epochs_data[train_idx], y_train)\n",
    "    preds[test_idx] = clf.predict(epochs_data[test_idx])\n",
    "\n",
    "# Printing the results\n",
    "acc = np.mean(preds == labels)\n",
    "print(\"Classification accuracy: %f \" % (acc))\n",
    "\n",
    "#names = ['audio left', 'audio right', 'vis left', 'vis right']\n",
    "#plot_confusion_matrix(preds, labels, names)\n",
    "#plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-3-7c5a99a2478d>, line 28)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"<ipython-input-3-7c5a99a2478d>\"\u001b[0;36m, line \u001b[0;32m28\u001b[0m\n\u001b[0;31m    -\u001b[0m\n\u001b[0m     ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# subject 1\n",
    "# Classification accuracy: 0.618750\n",
    "\n",
    "# subject 2\n",
    "# Classification accuracy: 0.768750 \n",
    "\n",
    "# subject 3\n",
    "# Classification accuracy: 0.950000 \n",
    "\n",
    "# subject 4\n",
    "# Classification accuracy: 0.787500 \n",
    "\n",
    "# subject 5\n",
    "# Classification accuracy: 0.725000\n",
    "\n",
    "# subject 6\n",
    "# Classification accuracy:  0.675000   \n",
    "\n",
    "# subject 7\n",
    "# Classification accuracy: 0.856250 \n",
    "\n",
    "# subject 8\n",
    "# Classification accuracy: 0.762500 \n",
    "\n",
    "# subject 9\n",
    "# Classification accuracy: 0.931250 \n",
    "-\n",
    "# subject 10\n",
    "# Classification accuracy: 0.681250\n",
    "\n",
    "# subject 11\n",
    "# Classification accuracy: 0.812500 \n",
    "\n",
    "# subject 12\n",
    "# Classification accuracy: 0.581250 \n",
    "\n",
    "# subject 13\n",
    "# Classification accuracy: 0.506250 \n",
    "\n",
    "# subject 14\n",
    "# Classification accuracy: 0.500000 \n",
    "\n",
    "# subject 1-14\n",
    "# Classification accuracy: 0.695536 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
